Trigonometry - Mailing list pgsql-general

From lynch@cognitivearts.com (Richard Lynch)
Subject Trigonometry
Date
Msg-id v02140b5fb34579b8c929@[207.152.64.133]
Whole thread Raw
Responses Re: [GENERAL] Trigonometry  (Statistical Solutions <statsol@statsol.com>)
List pgsql-general
I'm using:

PostgreSQL 6.3.2 on i686-pc-linux-gnu, compiled by gcc 2.7.2.3
('cuz that's what my ISP gots)

and there don't seem to be any trigonomeric functions, so I'm really up a
creek for trying to calculate latitude/longitude distances using:

create function radians(float4)  returns float4 as
'select 3.1415927 * $1 / 180'
language 'sql';

create function gpsdistance(float4, float4, float4, float4) returns float4 as
'select (3590 * (2 * atan2( sqrt(pow((sin(radians(($1 - $3))/2)),2) +
cos($4) * cos($2) * pow((sin(radians(($2 - $4))/2)),2)),
sqrt(1-(pow((sin(radians(($1 - $3))/2)),2) + cos($4) * cos($2) *
pow((sin(radians(($2 - $4))/2)),2))))))'
language 'sql';

The online docs don't seem to have anything about trig nor longitude
latitude, but I could have sworn somebody said that kind of stuff was in
PostgreSQL...

Any ideas, keeping in mind that installing a new PostgreSQL or adding stuff
to it that requires being root or even postgres super-user are not an
option?...

I *can* compile c code, so if somebody could 'splain to a Lisp hacker how
to make a gpsdistance.so that would maybe work?

-- "TANSTAAFL" Rich lynch@cognitivearts.com   webmaster@  and www. all of:
R&B/jazz/blues/rock - jademaze.com      music industry org - chatmusic.com
acoustic/funk/world-beat - astrakelly.com   sculptures - olivierledoux.com
my own nascent company - l-i-e.com   cool coffeehouse - uncommonground.com



pgsql-general by date:

Previous
From: dustin sallings
Date:
Subject: Re: [GENERAL] 9k limit?
Next
From: Martin Weinberg
Date:
Subject: Problem with an indexing on a large table. Suggestions needed.